package com.jar.exercise.网络编程.TCP连接.客服端和服务端;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 自定义服务器端，让浏览器访问
 */
public class Demo8 {
	public static void main(String[] args) throws IOException {
		ServerSocket serverSocket = new ServerSocket(12000);
		while (true) {
			Socket socket = serverSocket.accept();
			String hostAddress = socket.getInetAddress().getHostAddress();
			System.out.println(hostAddress);
			PrintWriter pw = new PrintWriter(socket.getOutputStream(), true);
			pw.println("<span>你好<span>");
			socket.close();
		}
	}
}
